import { ILoadMapTypeAll } from '@/common';
import { SchemaManageAPI } from '@/components/SchemaComponent/SchemaManage/type';
import { getLevelZeroJson, getLoadMapList, getSelectDataCommon, getTenantID } from '@/utils';

/**
 * @getProcurementMethodManageSearchColumns
 * @description 变更采购方式管理数据表格信息展示和操作
 */
export const getProcurementMethodManageSearchColumns = (): Array<SchemaManageAPI.ISearchList> => {
  const loadMdicIds: string[] = [
    `${getTenantID()}${ILoadMapTypeAll.CHANGEPURCHASE_ZFSTATE}`,
    `${getTenantID()}${ILoadMapTypeAll.PURCHASE_CHANGEWAY}`,
    `${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`,
  ];

  const { loadMapInfo } = getLoadMapList(loadMdicIds);

  const zf_state = getSelectDataCommon(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.CHANGEPURCHASE_ZFSTATE}`], 'name', 'id');
  const state = getSelectDataCommon(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_CHANGEWAY}`], 'name', 'id');

  return [
    {
      name: 'purchProjectName',
      placeholder: '采购项目名称',
      label: '采购项目名称',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'packName',
      placeholder: '标包名称',
      label: '标包名称',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },

    {
      name: 'procureDraft',
      placeholder: '变更前采购方式',
      label: '变更前采购方式',
      componentType: 'TreeSelect',
      allowClear: true,
      md: 4,
      sm: 24,
      treeID: 'id',
      treeName: 'name',
      whetherSenior: false,
      dataSource: loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`],
    },
    {
      name: 'procureReal',
      placeholder: '拟定采购方式',
      label: '拟定采购方式',
      componentType: 'TreeSelect',
      allowClear: true,
      md: 4,
      sm: 24,
      treeID: 'id',
      treeName: 'name',
      whetherSenior: false,
      dataSource: loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`],
    },
    {
      name: 'state',
      placeholder: '状态',
      label: '状态',
      componentType: 'Select',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
      dataSource: state,
    },
    {
      name: 'applyInfo',
      placeholder: '变更理由',
      label: '变更理由',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'expectSum',
      placeholder: '预算费用',
      label: '预算费用',
      componentType: 'NumberRange',
      allowClear: true,
      md: 8,
      sm: 24,
      whetherSenior: true,
    },

    // {
    //     name: 'checkState',
    //     placeholder: '审核状态',
    //     label: '审核状态',
    //     componentType: 'Select',
    //     allowClear: true,
    //     md: 4,
    //     sm: 24,
    //     whetherSenior: true,
    // },
    // {
    //     name: 'createTime',
    //     placeholder: '创建时间',
    //     label: '创建时间',
    //     componentType: 'RangePicker',
    //     allowClear: true,
    //     md: 6,
    //     sm: 24,
    //     whetherSenior: true,
    // },
    // {
    //     name: 'checkTime',
    //     placeholder: '审核时间',
    //     label: '审核时间',
    //     componentType: 'RangePicker',
    //     allowClear: true,
    //     md: 6,
    //     sm: 24,
    //     whetherSenior: true,
    // },

    {
      name: 'applyTime',
      placeholder: '申请时间',
      label: '申请时间',
      componentType: 'RangePicker',
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'applyFormName',
      placeholder: '申请',
      label: '申请',
      componentType: 'DeptAndUser',
      dataSource: getLevelZeroJson() ?? [],
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
      formOrgType: {
        COMP: 'applyCompanyID',
        DEPT: 'applyDepartmentID',
        POS: 'applyPositionID',
        USER: 'applyerID',
      },
    },
    // {
    //     name: 'cancelTime',
    //     placeholder: '取消时间',
    //     label: '取消时间',
    //     componentType: 'RangePicker',
    //     allowClear: true,
    //     md: 6,
    //     sm: 24,
    //     whetherSenior: true,
    // },
    // {
    //     name: 'cancelTime',
    //     placeholder: '作废时间',
    //     label: '作废时间',
    //     componentType: 'RangePicker',
    //     allowClear: true,
    //     md: 6,
    //     sm: 24,
    //     whetherSenior: true,
    // },
  ];
};
